import { cache } from "webpack";

export default {
  local:{
    set(key, item){
      let d = null;
      try{
        d = JSON.stringify(item);
      }
      catch(err){
        d = item
      }
      localStorage.setItem(key, d)
    },
    get(item){
      item = localStorage.getItem(item)
      let d = null;
      try{
        d = JSON.parse(item);
      }
      catch(err){
        d = item;
      }
      return d;
    }
  },
  session:{
    set(key, item){
      let d = null;
      try{
        d = JSON.stringify(item);
      }
      catch(err){
        d = item
      }
      sessionStorage.setItem(key, item)
    },
    get(item){
      item = sessionStorage.getItem(item)
      let d = null;
      try{
        d = JSON.parse(item);
      }
      catch(err){
        d = item;
      }
      return d;
    }
  }
}